package com.snake.springboot.authority.web.controller;

import com.snake.springboot.authority.api.model.AccountInfoModel;
import com.snake.springboot.authority.api.model.AuthSysAdminLoginModel;
import com.snake.springboot.authority.api.service.LoginSystemAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类 {@code LoginSystemAdminController}  <br> .
 * <p>登录-系统管理员
 * 创建时间：2025/01/14 9:12
 *
 * @author huang.yj
 */
@Api(tags = "登录-系统管理员")
@RestController
@RequestMapping("/login/system-admin")
public class LoginSystemAdminController {

    private LoginSystemAdminService loginSystemAdminService;

    @Autowired
    public LoginSystemAdminController(LoginSystemAdminService loginSystemAdminService) {
        this.loginSystemAdminService = loginSystemAdminService;
    }

    @ApiOperation("账号密码登录")
    @PostMapping("/password_login")
    public ResponseResult<AuthSysAdminLoginModel> loginByPassword(
            @ApiParam(name = "对象", value = "传入json格式", required = true)
            @RequestBody AuthSysAdminLoginModel model) throws Exception {
        AuthSysAdminLoginModel loginModel = loginSystemAdminService.loginByPassword(model);
        return ResponseResultFactory.ucc("登录成功！！",loginModel);
    }

    @ApiOperation("获取账号信息")
    @PostMapping("/get_account")
    public ResponseResult<AccountInfoModel> getSystemAdminAccount(
            @ApiParam(name = "对象", value = "传入json格式", required = true)
            @RequestBody AccountInfoModel model) {
        AccountInfoModel accountInfoModel = loginSystemAdminService.getAccount(model);
        return ResponseResultFactory.ucc("获取账号信息成功！！",accountInfoModel);
    }
}
